import _ from 'lodash'
export default {
	data() {
		return {
			dialogVisible:false,
			operType:'',//['edit'|'add']
			node:'山东省',
			resetForm:null,
		}
	},
	created(){
		this.resetForm = _.cloneDeep(this.form)
	},
	methods:{
		handleNodeClick(data) {
			this.node = data.label
			this.fetchList()
		},
		handleConfirm(){
			this.$refs.ruleForm.validate(valid => {
				if(valid){
					if(this.operType === 'add'){
						this.fetchAdd()
					}else if(this.operType === 'edit'){
						this.fetchUpdate()
					}else{
						return
					}
					this.fetchList()
					this.dialogVisible = false
				}
			})
		},
		handleAdd() {
			this.operType = 'add'
			this.form = this.resetForm
			this.dialogVisible = true
			this.$nextTick(() => this.$refs.ruleForm.clearValidate())
		},
		handleEdit(item) {
			this.operType = 'edit'
			this.form = item
			this.dialogVisible = true
			this.$nextTick(() => this.$refs.ruleForm.clearValidate())
		},
		handleDelete(id) {
			this.$confirm('此操作将永久删除, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				this.fetchDelete(id)
			}).catch(() => {
				
			});
		},
		fetchDelete(){},
		fetchAdd(){},
		fetchUpdate(){},
	}
}